package com.lucy.common.converter;

import com.lucy.common.utils.JsonUtil;

import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import java.util.HashMap;
import java.util.Map;

@Converter
public class MapConverter implements AttributeConverter<Map<String,Object>,String> {
    @Override
    public String convertToDatabaseColumn(Map<String, Object> stringObjectMap) {
        return JsonUtil.obj2String(stringObjectMap);
    }

    @Override
    public Map<String, Object> convertToEntityAttribute(String s) {
        return JsonUtil.string2Obj(s,Map.class);
    }
}
